home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_084 / ed / esc.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  719b  |  42 lines

  1. #include <stdio.h>
  2. #include "tools.h"
  3.  
  4. /* Map escape sequences into their equivalent symbols.  Returns the
  5.  * correct ASCII character.  If no escape prefix is present then s
  6.  * is untouched and *s is returned, otherwise **s is advanced to point
  7.  * at the escaped character and the translated character is returned.
  8.  */
  9. esc(s)
  10. char    **s;
  11. {
  12.     register int    rval;
  13.  
  14.     
  15.     if (**s != ESCAPE)
  16.     {
  17.         rval = **s;
  18.     } else {
  19.         (*s)++;
  20.  
  21.         switch(toupper(**s))
  22.         {
  23.         case '\000':
  24.             rval = ESCAPE;    break;
  25.         case 'S':
  26.             rval = ' ';    break;
  27.         case 'N':
  28.             rval = '\n';    break;
  29.         case 'T':
  30.             rval = '\t';    break;
  31.         case 'B':
  32.             rval = '\b';    break;
  33.         case 'R':
  34.             rval = '\r';    break;
  35.         default:
  36.             rval = **s;    break;
  37.         }
  38.     }
  39.  
  40.     return (rval);
  41. }
  42.